//
//  ArticleInfoData.m
//  EnvironmentalProtection
//
//  Created by HCreater on 2018/11/17.
//  Copyright © 2018年 HCreater. All rights reserved.
//

#import "ArticleInfoData.h"

@implementation ArticleInfoData

- (BOOL)isCollect
{
    return ![self.ifCollect isEqualToString:@"0"];
}

- (BOOL)isPraise
{
    return ![self.ifPraise isEqualToString:@"0"];
}

/// 属性map
+ (NSDictionary<NSString *,id> *)modelCustomPropertyMapper
{
    return @{
             @"articleID":@"article_id",
             @"cateID":@"cate_id",
             @"userID":@"user_id",
             @"isTop":@"is_top",
             @"provinceID":@"province_id",
             @"areaID":@"area_id",
             @"downloadCount":@"download_count",
             @"readCount":@"read_count",
             @"isCharge":@"is_charge",
             @"addTime":@"addtime",
             @"ifCollect":@"if_collect",
             @"ifPraise":@"if_praise",
             @"commentCount":@"comment_count",
             @"collectCount":@"collect_count",
             @"praiseCount":@"praise_count",
             };
}

/// 属性名 生成 class
+ (NSDictionary<NSString *,id> *)modelContainerPropertyGenericClass
{
    return @{
             @"user":[UserInfoData class],
             };
}

- (OfflineFileDBData*)dbData
{
    OfflineFileDBData* dbData = [[OfflineFileDBData alloc] init];
    dbData.articleID = self.articleID;
    dbData.name = self.title;
    dbData.fileUrl = self.download;
    dbData.date = self.addTime;
    
    return dbData;
}

@end
